#include <wfcClient.h>
#include <pfcGlobal.h>
#include <uifcDefaultListeners.h>
#include <wxyutils.h>

wfcStatus GetFeatures()
{
    xstring dialogname = "TreeInteraction";
    xstring treename = "Tree";
    pfcSession_ptr session = pfcGetProESession();
    uifcCreateDialog(dialogname, dialogname);
    uifcDialog_ptr dialog = uifcDialogFind(dialogname, dialogname);
    dialog->AddActionListener(new CloseDialogListener());
    try
    {
        uifcTree_ptr Tree = uifcTreeFind(dialogname, treename);
        LOG(LOG_INFO) << Tree;
        uifcTreeItem_ptr T0 = uifcTreeItemDefine("T0");
        uifcItemPositionData_ptr IPos = uifcItemPositionData::Create();
        Tree->InsertItem(T0, IPos);
        LOG(LOG_INFO) << Tree->GetRootItemName();

        uifcTreeItem_ptr T1 = uifcTreeItemDefine("T1");
        // T1 = uifcTreeItemFind(dialogname, treename, "T1");
        uifcItemPositionData_ptr IPos1 = uifcItemPositionData::Create();
        // Tree->InsertItem(T1, IPos1);
        // // T1->SetParentName("T0");
        // T1->SetIsVisible(xtrue);
        // T1->SetIsEnabled(xtrue);

        // T1->CreateInParent((uifcComponent_ptr)Tree, IPos1);
        // LOG(LOG_INFO) << "Is Visible:" << T1->IsVisible();
        // LOG(LOG_INFO) << "Is Enabled:" << T1->IsEnabled();
        // LOG(LOG_INFO) << "Is Open:" << T1->IsOpen();
        LOG(LOG_INFO) << Tree->GetNodeTypeNameArray()->get(0);
        xstringsequence_ptr nodes = xstringsequence::create();
        for (int i = 0; i < 5; i++)
        {
            string buf = "T" + to_string(i + 1);
            nodes->append(xstring(buf.c_str()));
        }
        Tree->SetNodeTypeNameArray(nodes);
    }
    OTK_EXCEPTION_PRINT_LOG
    uifcActivateDialog(dialogname);
    uifcDestroyDialog(dialogname);
    return wfcTK_NO_ERROR;
}